﻿using IntelligentAgriculture.Contracts.Dto.Input;
using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.GermlineHistoryRecordsCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.GermlineHistoryRecordsCommandHandler
{
    /// <summary>
    /// 种母历史记录显示查询CommandHandler
    /// </summary>
    public class SelectHistoryRecordsCommandHandler : IRequestHandler<SelectHistoryRecordsCommand, Results<PageOutput<HistoryOutPut>>>
    {

        private readonly IHistoryRecordService _service;
        public SelectHistoryRecordsCommandHandler(IHistoryRecordService service)
        {
            _service = service;
        }

        public async Task<Results<PageOutput<HistoryOutPut>>> Handle(SelectHistoryRecordsCommand request, CancellationToken cancellationToken)
        {
            var list = await _service.GetHistoryRecordsAsync(request.Input);
            return Results<PageOutput<HistoryOutPut>>.DataResult(list);
        }
    }
}
